#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int N=1e6+10;
#define INF 0x3f3f3f3f3f
int a[N];
int b[N];
const int M=1010;
void solve()
{
int n;
cin>>n;
for(int i=1;i<=n;++i)
cin>>a[i]>>b[i];
int p=0,q=0,ans=0;
for(int i=1;i<=n;i++)
{
int ti;
if(p==q)
q=b[i];
if(i==n||a[i+1]-a[i]>=abs(p-q))
ti=q;
else
if (p < q)
ti = p + a[i + 1] - a[i];
else
ti = p - a[i + 1] + a[i];
if((b[i]-ti)*(b[i]-p)<=0)
ans++;
p=ti;
}
cout<<ans<<endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
//t = 1;
cin>>t;
while (t--)
{
solve();
}
}
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |
123. Best Time to Buy and Sell Stock III | 85. Maximal Rectangle |
84. Largest Rectangle in Histogram | 60. Permutation Sequence |
42. Trapping Rain Water | 32. Longest Valid Parentheses |
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |
Back to School | I am Easy |
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |